﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using QLKS2014.PUBLIC;
using System.Data;
using System.Windows.Forms;

namespace QLKS2014.DATA
{
    public class ThamSoData
    {
        DataConnecter connect;
        public ThamSoData()
        {
            connect = new DataConnecter();
        }

        public List<ThamSoPublic> selectAll()
        {
            try
            {
                DataTable dt = new DataTable();
                List<ThamSoPublic> list = new List<ThamSoPublic>();
               
                int row;
                dt = connect.getData("ThamSo_SelectAll");
                row = dt.Rows.Count;
                for (int i = 0; i < row; i++)
                {
                    ThamSoPublic thamSoPublic = new ThamSoPublic();

                    thamSoPublic.MaThamSo = int.Parse(dt.Rows[i].ItemArray[0].ToString());
                    thamSoPublic.TenThamSo = dt.Rows[i].ItemArray[1].ToString();
                    thamSoPublic.GiaTri = float.Parse(dt.Rows[i].ItemArray[2].ToString());
                    list.Add(thamSoPublic);
                }
                return list;
            }
            catch(Exception ex)
            {
                //bao loi
                MessageBox.Show(ex.Message, "Không Thể Load Dữ Liệu");
                return null;
            }
        }

    }
}
